var status = -1;
var npcs = [9400920, 9400921, 9401160];

function start() {
    action(1, 0, 0)
}

function action(e, c, b) {
    (e == 1) ? status++ : status--;
    var a = -1;
    if (status <= a++) {
        cm.dispose()
    } else {
        if (status === a++) {
            if (!cm.isQuestFinished(500763)) {
                cm.dispose();
                cm.startQuestScript(0, 500763);
                return
            }
            if (cm.getNpc() == 0 || cm.getNpc() == cm.getPlayer().getAccountId()) {
                var d = "我"
            } else {
                var d = "别人"
            }
            cm.dispose()
        } else {
            if (status === a++) {
                cm.updateInfoQuest(64590, "rMap=" + cm.getMapId());
                cm.dispose();
                if (cm.getPlayer().getQuestStatus(64591) == 1) {
                    cm.warp(871000011)
                } else {
                    if (cm.getNpc() == cm.getPlayer().getAccountId()) {
                        cm.enterHome(0)
                    } else {
                        cm.enterHome(cm.getNpc())
                    }
                }
            }
        }
    }
};